package com.sinosoft.perfect.system._.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

public abstract class SystemUtil {
	
	public static String getRandomNumberByNum(int num)    
	{   
		StringBuffer sb = new StringBuffer();   
		for (int i = 0; i < num; i++)    
		{   
		    long randomNum = Math.round(Math.floor((Math.random() * 10)));  
		    sb.append(randomNum+""); 
		}   
		return sb+"";   
	}
	
	public static String md5(String msg) throws NoSuchAlgorithmException {
	   MessageDigest md = MessageDigest.getInstance("MD5");
	   BASE64Encoder encoder = new BASE64Encoder();
	   return encoder.encode(md.digest(msg.getBytes()));
	}
	
}
